import request from 'utils/request/request';
import Config from 'utils/api'
import { createTheURL } from 'utils/utils';

export async function getUserSessions(params) {
  return request(createTheURL(Config.USERS_SESSION, params.Session), {
    method: 'get'
  });
}
export async function getJsapiSign(params) {
  return request(window.location.origin+Config.DD_JSAPI, {
    method: 'post',
    body:params
  });
}
export async function getPersonalUsers(params) {
  return request(createTheURL(Config.USERS, params.userWsid), {
    method: 'get',
  });
}
export async function getEnterpriseUsers(params) {
  return request(createTheURL(Config.ENTERPRISE_USERS, params.userWsid), {
    method: 'get',
  });
}

export async function getEnterpriseData(params) {
  console.log(params)
  return request(createTheURL(Config.ENTERPRISE_DATA, params), {
    method: 'get',
  });
}

//下载文件
export async function getFile(params) {
  return request(createTheURL(Config.FILE,params.fileId), {
    method: 'get',
  },'IMAGE_TYPE');
}

export async function getPDFList(params) {
  const envelopeWsid = localStorage.getItem("envelopeWsid");
  const url = Config.PDF_LIST + envelopeWsid
  return request(createTheURL(url,'contents'), {
    method: 'get',
    body: params
  });
}
export async function getPDFDetail(params) {
  return request(createTheURL(Config.FILE,params.id), {
    method: 'get',
  }, 'IMAGE_TYPE');
}
export async function getIntendCertification(params) {
  return request(createTheURL(Config.INTEND_CERTIFICATION,'init'), {
    method: 'post',
    body: params
  });
}

export async function getIntendCertificationResult(params) {
  return request(createTheURL(Config.INTEND_CERTIFICATION,'result'), {
    method: 'get',
    body: params
  });
}
export async function getPersonData(params) {
  return request(createTheURL(Config.SUBMITENTERPRISEINFO,params), {
    method: 'get'
  });
}

export async function getPersonCertification(params) {
  return request(createTheURL(Config.PERSON_CERTIFICATION,params), {
    method: 'get'
  });
}

export async function getSignedPDF(params) {
  return request(createTheURL(Config.SIGNED_PDFVIEWER,'preview'), {
    method: 'get',
    body: params
  });
}
export async function getUserPermiss(params) {
  const api=Config.USER_PERMISS+'/'+localStorage.getItem("userWsid")
  return request(createTheURL(api,'check-privilege'), {
    method: 'post',
    body: params
  });
}
